﻿namespace FasadPattern.Composits
{
    using System;
    using FasadPattern.SerializeWorker;
    using FasadPattern.SerializeWorker.JSONObjects;

    public class Cactus : IAssignable
    {
        #region Properties

        public int Height
        {
            get { return m_Height; }
            set { m_Height = value; }
        }

        public int Radius
        {
            get { return m_Radius; }
            set { m_Radius = value; }
        }

        public string Color
        {
            get { return m_Color; }
            set { m_Color = value; }
        }

        public int AmountOfPrickles
        {
            get { return m_amountOfPrickles; }
            set { m_amountOfPrickles = value; }
        }

        public bool CanBlossom
        {
            get { return m_CanBlossom; }
            set { m_CanBlossom = value; }
        }

        public string Region
        {
            get { return m_Region; }
            set { m_Region = value; }
        }

        public bool ForTequila
        {
            get { return m_ForTequila; }
            set { m_ForTequila = value; }
        }

        public string Shape
        {
            get { return m_Shape; }
            set { m_Shape = value; }
        }

        public string Soil
        {
            get { return m_Soil; }
            set { m_Soil = value; }
        }

        public string Climate
        {
            get { return m_Climate; }
            set { m_Climate = value; }
        }

        public double Weight
        {
            get { return m_Weight; }
            set { m_Weight = value; }
        }

        public decimal Price
        {
            get { return m_Price; }
            set { m_Price = value; }
        }

        #endregion

        #region Methods

        public void Grow()
        {

        }

        public void Prick()
        {

        }

        public void Blossom()
        {

        }

        #endregion

        #region IAssiagnsble Implementation

        /// <summary>
        /// Transfares content
        /// </summary>
        /// <param name="obj">Object to transfare</param>
        public void AssignTo(object obj)
        {
            if (obj == null)
                throw new ArgumentNullException();

            if (obj is Cactus)
            {
                Cactus cact = obj as Cactus;
                cact.Height = this.Height;
                cact.AmountOfPrickles = this.AmountOfPrickles;
                cact.CanBlossom = this.CanBlossom;
                cact.Climate = this.Climate;
                cact.Color = this.Color;
                cact.ForTequila = this.ForTequila;
                cact.Price = this.Price;
                cact.Radius = this.Radius;
                cact.Region = this.Region;
                cact.Shape = this.Shape;
                cact.Soil = this.Soil;
                cact.Weight = this.Weight;

                return;
            }

            if (obj is JSONObject)
            {
                JSONObject result = obj as JSONObject;
                JSONSerializer ser = new JSONSerializer();
                result.EncodedStreamList = ser.Serialize(this).EncodedStreamList;

                return;
            }

            throw new NotSupportedException();
        }

        #endregion

        #region Private Fields

        private int m_amountOfPrickles;

        private int m_Height;

        private int m_Radius;

        private string m_Color = "green";

        private bool m_CanBlossom = false;

        private string m_Region = "no region";

        private bool m_ForTequila = false;

        private string m_Shape = "no shape";

        private string m_Soil = "no soil";

        private string m_Climate = "no climate";

        private double m_Weight;

        private decimal m_Price;

        #endregion
    }
}
